package com.qifei.xmlg_backend.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.qifei.xmlg_backend.entity.Student;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 学生表 Mapper 接口
 * </p>
 *
 * @author qifei
 * @since 2025-06-11
 */
public interface StudentMapper extends BaseMapper<Student> {

    /**
     * 获取学生性别统计数据
     * @return 性别和对应的人数
     */
    @Select("SELECT gender, COUNT(*) as count FROM student GROUP BY gender")
    List<Map<String, Object>> getStudentGenderStats();

    /**
     * 获取学生状态统计数据
     * @return 状态和对应的人数
     */
    @Select("SELECT status, COUNT(*) as count FROM student GROUP BY status")
    List<Map<String, Object>> getStudentStatusStats();

    /**
     * 获取学生加入时间统计数据（按月份）
     * @return 月份和对应的加入人数
     */
    @Select("SELECT MONTH(join_date) as month, COUNT(*) as count FROM student GROUP BY MONTH(join_date) ORDER BY month")
    List<Map<String, Object>> getStudentJoinDateStats();
}
